﻿Public Class Posicion
    Private x As Integer
    Private y As Integer
    Public Sub New()
        x = 0
        y = 0
    End Sub
    Public Sub New(ByVal p As Posicion)
        Me.x = p.x
        Me.y = p.y

    End Sub

    Public Sub New(ByVal s As String)

        Dim cadena As String = s
        cadena = cadena.Trim("(")
        cadena = cadena.Trim(")")
        x = cadena.Remove(0, cadena.IndexOf(","))
        y = cadena.Remove(cadena.IndexOf(","), cadena.Length)
        
    End Sub

    Public Sub New(ByVal x As Integer, ByVal y As Integer)
        x = x
        y = y

    End Sub

    Public Property pX() As Integer
        Get
            Return x
        End Get
        Set(ByVal value As Integer)
            x = value
        End Set
    End Property

    Public Property py() As Integer
        Get
            Return y
        End Get
        Set(ByVal value As Integer)
            y = value
        End Set
    End Property

    Public Overrides Function equals(ByVal o As Object) As Boolean
        If TypeOf o Is Posicion Then
            Dim p As Posicion = CType(o, Posicion)
            Return Me.x = p.x And Me.y = p.y
        End If
    End Function
    Public Function hashCode() As Integer
        Return Me.hashCode
    End Function

    Public Overrides Function toString() As String
        Return "(" & Me.x & "," & Me.y & ")"
    End Function

End Class
